#Faces are user images
#require 'RMagick'

class Face < Asset
#include Magick

  belongs_to :friend

  has_attachment  :content_type => :image,
                  :storage      => :file_system,
                  :processor    => :rmagick,
                  :path_prefix  => "public/assets/faces",
                  :size         => 1..333.kilobytes,
                  :thumbnails   => { :icon => "33x33!",
                                     :display => "77x77!"}

  validates_as_attachment

  def test_resize_image(img, size)
    # Get rid of all colour profiles.  They take up a lot of space.
    #img.strip!
    super

    width = img.columns
    height = img.rows
    # create a masq of same size
    masq = Magick::Image.new(width, height)
    masq.color_reset!("#88F8F8")
    d = Magick::Draw.new
    # 10 is the corner's radius
    d.roundrectangle(0, 0, width - 1, height - 1, 10, 10)
    d.draw(masq)

    self.temp_path = write_to_temp_file(img.composite(masq, 0, 0, Magick::LightenCompositeOp).to_blob)
  end




end
